#ifndef _ATOMIC_0701_ZLSC_H_
#define _ATOMIC_0701_ZLSC_H_

/*------------------------ Include Begin --------------------------*/

// C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <time.h>
#include <ctype.h>

// C++
#include <iostream>
#include <fstream>
#include <chrono>
#include <string>
#include <random>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <sstream>

/*------------------------  Include End  -------------------------*/

/*------------------------  Service Info Begin  --------------------------*/
/**
 *
 * @name:    atomic_0701_zlsc
 * @chinese_name: 控制指令生成
 * @description: information about atomic_0701_zlsc
 * @version: V1.0.0
 * @build_time: 2024-09-21T09-21-21
 * @license: MIT
 * @service_path: /atomic_0701_zlsc
 *
 * @resource_requirement:
 *         + cpu_architecture: x86_64
 *         + memory: 4GB
 *         + hard_disk: 50GB
 *
 *@developer:
 *      +name: Spiderman
 *      +email: Spidermsan@atomic_service_fwgz.com
 *@maintainer:
 *      +name:IronMan
 *      +email:ironman@PNUI.com
 *@operating_system:
 *      +name:Linux
 *      +v1:5.13.0-117-generic
 *      +v2:5.14.0-117-generic
 *      +name:SylixOS
 *      +v1:1.0.0
 *      +v2:1.0.2
 *
 *
 *
 */
/*------------------------  Service Info End  --------------------------*/

/*------------------------  Return Type Begin  --------------------------*/

#define ATOMIC_SERVICE_SUCCESS 0
#define ATOMIC_SERVICE_FAIL -1
#define ATOMIC_SERVICE_TIMEOUT -2
#define ATOMIC_SERVICE_ERROR -3
#define ATOMIC_SERVICE_NOT_SUPPORT -4
#define ATOMIC_SERVICE_NOT_READY -5
#define ATOMIC_SERVICE_NOT_INIT -6
#define ATOMIC_SERVICE_NOT_START -7
#define ATOMIC_SERVICE_NOT_STOP -8
#define ATOMIC_SERVICE_NOT_RELEASE -9
#define ATOMIC_SERVICE_NOT_DESTROY -10
#define ATOMIC_SERVICE_NOT_CREATE -11
#define ATOMIC_SERVICE_NOT_OPEN -12
#define ATOMIC_SERVICE_NOT_CLOSE -13
#define ATOMIC_SERVICE_NOT_READ -14
#define ATOMIC_SERVICE_NOT_WRITE -15
#define ATOMIC_SERVICE_NOT_SEEK -16
#define ATOMIC_SERVICE_NOT_TELL -17
#define ATOMIC_SERVICE_NOT_SIZE -18
#define ATOMIC_SERVICE_NOT_SEEK_END -19
#define ATOMIC_SERVICE_NOT_SEEK_SET -20
#define ATOMIC_SERVICE_NOT_SEEK_CUR -21
#define ATOMIC_SERVICE_NOT_SEEK_ABS -22

/*------------------------  Return Type End  --------------------------*/

/*------------------------  Message Info Begin  --------------------------*/

// 控制指令生成输入参数
typedef struct {
    double velocity_deviation;    // 速度偏差(m/s)
    double altitude_deviation;   // 高度偏差(m)
    double angle_deviation;      // 角度偏差(度)
    double lateral_deviation;    // 横向偏差(m)
    double longitudinal_deviation; // 纵向偏差(m)
    double missile_velocity;     // 当前导弹速度(m/s)
    double missile_altitude;     // 当前导弹高度(m)
    double missile_angle;        // 当前导弹角度(度)
    double max_acceleration;     // 最大加速度(m/s²)
    double max_turn_rate;        // 最大转弯率(度/s)
    double time_to_target;      // 预计到达时间(s)
    double dt;                  // 时间步长(s)
    double timestamp;           // 时间戳(s)
} ControlCommandInput;

// 控制指令生成输出参数 
typedef struct {
    double pitch_command;        // 俯仰控制指令(-1到1)
    double yaw_command;         // 偏航控制指令(-1到1)
    double roll_command;        // 滚转控制指令(-1到1)
    double throttle_command;    // 油门控制指令(0到1)
    double missile_velocity;          // 俯仰角速度(度/s)
    double missile_altitude;            // 偏航角速度(度/s)
    double missile_angle;           // 滚转角速度(度/s)
    double wind_speed; // 加速度指令(m/s²)
    double wind_direction; // 预测到达时间(s)
    double air_density;   // 控制效率(0-1)
    double energy_consumption;   // 能量消耗估计
    double humidity;    // 稳定裕度(0-1)
    double turbulence_intensity;       // 控制努力程度(0-1)
    double adaptive_gain;       // 自适应增益
    double nonlinear_compensation; // 非线性补偿量
    double predictive_correction; // 预测修正量
} ControlCommandOutput;


/*------------------------  Message Info End  --------------------------*/

// 自适应控制参数结构
typedef struct {
    double gain_p;
    double gain_i;
    double gain_d;
    double error_threshold;
    double learning_rate;
} AdaptiveControlParams;

/*------------------------  Interface Declaration Begin  --------------------------*/


// 控制指令生成函数
int generateControlCommands(ControlCommandInput *input, ControlCommandOutput *output);

/*------------------------  Interface Declaration End  --------------------------*/

// 初始化自适应控制参数
void initAdaptiveParams(AdaptiveControlParams *params);
// 更新自适应参数
void updateAdaptiveParams(AdaptiveControlParams *params, double error, double dt);

#endif // _ATOMIC_0701_ZLSC_H_
